package com.xd.core.system.controller;


import com.xd.core.system.entity.CityInfo;
import com.xd.core.system.entity.ProvincesInfo;
import com.xd.core.system.service.ICityInfoService;
import com.xd.core.system.service.IProvincesInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author SJ
 * @since 2023-03-28
 */
@Api(tags = "地图树形结构")
@RestController
@RequestMapping("/custom/city-info")
public class CityInfoController {
    @Autowired
    private ICityInfoService cityInfoService;
    @Autowired
    private IProvincesInfoService iProvincesInfoService;
    @ApiOperation(value = "获取地区树形结构", notes = "-")
    @GetMapping("getCity")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "head", value = "是否要全国", dataType = "boolean")
    })
    public List<CityInfo> getCity(boolean head) {
        List<CityInfo> cityInfo = cityInfoService.getCity(head);
        return cityInfo;
    }


    @ApiOperation(value = "获取省市区", notes = "-")
    @GetMapping("getProvince")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "head", value = "是否要全国(true要 false不要)", dataType = "boolean")
    })
    public List<ProvincesInfo> getProvince(boolean head) {
        List<ProvincesInfo> provinceInfo = iProvincesInfoService.getProvince(head);
        return provinceInfo;
    }

    @ApiOperation(value = "H5获取地区树形结构", notes = "-")
    @GetMapping("getCityH5")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "head", value = "是否要全国", dataType = "boolean")
    })
    public List<CityInfo> getCityH5(boolean head) {
        return cityInfoService.getCity(head);
    }

}
